package com.zretc.kscxmz.controller.tongxunlu;

import com.github.pagehelper.PageInfo;
import com.zretc.kscxmz.entity.tongxunlu.Contacts;
import com.zretc.kscxmz.services.ContactsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/contacts")
public class ContactsController {

    private Logger logger = LoggerFactory.getLogger(ContactsController.class);

    @Autowired
    private ContactsService contactsService;
    @RequestMapping("/getContactsByPage")
    @ResponseBody
    public PageInfo<Contacts> getContactsByPage(@RequestParam("accountName") String accountName,
                                                @RequestParam("pageNum") Integer pageNum,
                                                @RequestParam("pageSize") Integer pageSize){

        PageInfo<Contacts> contacts = contactsService.getContactsByPage(accountName,pageNum, pageSize);

        return contacts;
    }

    @RequestMapping("/getContactsByLetter")
    @ResponseBody
    public PageInfo<Contacts> getContactsByLetter(@RequestParam("letter") String letter,
                                                @RequestParam("pageNum") Integer pageNum,
                                                @RequestParam("pageSize") Integer pageSize){

        PageInfo<Contacts> contacts = contactsService.getContactsByLetter(letter,pageNum, pageSize);

        return contacts;
    }
}
